﻿using System.Globalization;

namespace KinonekoSoftware.Studio.Resources.Converters
{
    public class BoolToOpacityConverter : OneWayConverter
    {
        private readonly object True = 1d;
        private          object _boxing;
        private          double _opacity;

        public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var v = value is bool b && b;
            return v ? True : _boxing;
        }

        public double Opacity
        {
            get => _opacity;
            set
            {
                _opacity = value;
                _boxing  = _opacity;
            }
        }
    }
}